package com.lp;

import com.lp.entity.Child;
import com.lp.entity.Father;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class BugTest {
    public static void main(String[] args) {
//        Child[] children = new Child[]{new Child(),new Child()};
//        System.out.println(children);
//        Father[] fathers = children;
//        System.out.println(fathers);
//        //bug Exception
//        fathers[0] = new Father();

        List<String> aaa = Arrays.asList("aaa");
        System.out.println(aaa.getClass());
        Object[] objects = aaa.toArray();
        System.out.println(objects);
        //bug ArrayStoreException
        objects[0] = new Object();

        List<String> list = new ArrayList<>();
        list.add("aaa");
        list.add("bbb");
        Object[] array = list.toArray();
        System.out.println(array.getClass());
        array[0] = "ccc";
        array[0] = 123;
        array[0] = new Object();
    }
}
